﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using Tools;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
   public class IndexDAL
   {
       #region
       /// <summary>
       /// 图书类型
       /// </summary>
       /// <returns></returns>
       public static List<BookType> BookTypeList()
       {
           string str = "select * from BookType";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookType> BookTypeList = new List<BookType>();
           while (sdr.Read())
           {
               BookType BookType1 = new BookType();
               BookType1.TypeID = (int)sdr["TypeID"];
               BookType1.TypeName = (string)sdr["TypeName"];
               BookType1.State = (int)sdr["State"];
               BookTypeList.Add(BookType1);
           }
           sdr.Close();
           return BookTypeList;
       }
       #endregion
       #region
       /// <summary>
       /// 图书表
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoList()
       {
           string str = "select top 10 * from BookInfo";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookNum = (string)sdr["BookNum"];
               BookInfoList1.State = (int)sdr["State"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.OriginalPrice = (decimal)sdr["OriginalPrice"];
               BookInfoList1.PresentPrice = (decimal)sdr["PresentPrice"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList1.Pubishing = (string)sdr["Pubishing"];
               BookInfoList1.PublicaDate = (DateTime)sdr["PublicaDate"];
             BookInfoList1.Chapter = (string)sdr["Chapter"];
             BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 详情
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoListtop(int id=0)
       {
           string str = "select * from BookInfo where BookID="+id;
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookNum = (string)sdr["BookNum"];
               BookInfoList1.State = (int)sdr["State"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.OriginalPrice = (decimal)sdr["OriginalPrice"];
               BookInfoList1.PresentPrice = (decimal)sdr["PresentPrice"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList1.AuthorDesc = (string)sdr["AuthorDesc"];
               BookInfoList1.Preface = (string)sdr["Preface"];
               BookInfoList1.BookDescMax = (string)sdr["BookDescMax"];
               BookInfoList1.Chapter = (string)sdr["Chapter"];
               BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 小说
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoListt()
       {
           string str = "select * from BookInfo where TypeID=4";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookName = (string)sdr["BookName"];
              BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
                BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 童书
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoLists()
       {
           string str = "select * from BookInfo where TypeID=3";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 青春
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoListq()
       {
           string str = "select * from BookInfo where TypeID=5";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 家庭教育
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoListj()
       {
           string str = "select * from BookInfo where TypeID=9";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 社会科学
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoListk()
       {
           string str = "select * from BookInfo where TypeID=6";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
       #region
       /// <summary>
       /// 经济管理
       /// </summary>
       /// <returns></returns>
       public static List<BookInfo> BookInfoListg()
       {
           string str = "select * from BookInfo where TypeID=7";
           SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(str);
           List<BookInfo> BookInfoList = new List<BookInfo>();
           while (sdr.Read())
           {
               BookInfo BookInfoList1 = new BookInfo();
               BookInfoList1.BookID = (int)sdr["BookID"];
               BookInfoList1.BookName = (string)sdr["BookName"];
               BookInfoList1.BookDesc = (string)sdr["BookDesc"];
               BookInfoList1.Pic = (string)sdr["Pic"];
               BookInfoList1.TypeID = (int)sdr["TypeID"];
               BookInfoList1.Author = (string)sdr["Author"];
               BookInfoList.Add(BookInfoList1);
           }
           sdr.Close();
           return BookInfoList;
       }
       #endregion
   }
}
